<!doctype html>
<html lang="cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>编辑资料</title>
    <link rel="stylesheet" href="/static/app/lib/iconfont/iconfont.css">
    <link rel="stylesheet" href="/static/app/css/style.css">
    <script src="/static/app/lib/zy.rem.js"></script>
    <script src="/static/app/lib/jquery1.12.3.min.js"></script>
    <script src="/static/app/js/base.js"></script>
    <link rel="stylesheet" href="/static/app/css/core.css">
    <script src="/static/layer/layer.min.js"></script>

    <style>
        .add{
            width: 64%;
            height: 0.4rem;
            
            background:transparent;
            border:none;
            outline:medium;
        }
        .lad{
            margin-left: 0.6rem;
            color: #000;
            font-size: 0.25rem;
        }
        .info-links{
            margin-top: 0.5rem;
        }
        .button_lar{
            width: 90%;
            height: 0.7rem;
            margin-left: 5%;
            margin-top: 2rem;
            color: #fff;
            font-size: 0.3rem;
            border: 0;
            border-radius:0.1rem;
            background-color: #0b76ac;
            outline:none;
        }
        .wenzhi{
            color: #000000;
        }
        .annn {
            width: 28%;
            height: 0.6rem;
            /* margin-left: 0%; */
            margin-top: 0.5rem;
            color: #fff;
            font-size: 0.26rem;
            border: 0;
            border-radius: 0.1rem;
            background-color: #0b76ac;
            outline: none;
        }

        .toxian{
            margin-left: 0.55rem;
            opacity: 0;
        }
        .abs{
            width: 20%;
            height: 0.5rem;
            margin-left: 5%;
            color: #fff;
            font-size: 0.3rem;
            border: 0;
            border-radius:0.1rem;
            background-color: #0b76ac;
            outline:none;
            position:absolute;
            top: 0.3rem;
            left: 1rem;
        }
        .toux{
            position: relative;
        }
    </style>
</head>
<body>
<div class="header">
    <div>
        <a href="javascript:history.back(-1)">
        <img src="/static/app/img/fanh.png"></a>
    </div>
    <div>设备管理</div>
    <div></div>
    <!--<div><a href="javascript:;" class="head-btn iconfont">&#xe765;</a></div>-->
</div>
<div class="center">
    <form action="{:url('upEqu')}" enctype="multipart/form-data" method="post">

        <div class="info">
            <div class="info-tou">
                <img src="{if $data.head!=null}{$data.head}{else}/static/app/img/toux.png{/if}" id="fileimg" onclick="toux_button()">
                <input class="toxian"  type="file" onChange="handleFiles(this,0)" name="img_head" accept="image/*">
            </div>
            <h3>{$Think.session.appuser.nickname}</h3>
        </div>
        <div class="info-links">
                <a href="javascript:;">IMEM： <span class="wenzhi">{$data['name']}</span></a>
                <a href="javascript:;">设备昵称：<input type="text" class="add" name="nickname" value="{$data.nickname}" required="ture" placeholder="请输入昵称"></a>
                <a href="javascript:;">到期时间： <span class="wenzhi">{$data.expire_time|date='Y-m-d',###}</span></a>
                <button type="button" onclick="del_button({$data.name})" class="annn">解除绑定</button>

            <a href="javascript:;">
                <input type="hidden" class="add" name="id" value="{$data.id}">

                <button class="button_lar">保存</button>
            </a>
        </div>
    </form>

</div>
<!--{include file='public:bottom'}-->
<script>
    // 取消绑定
    function del_button(name) {
        layer.confirm("确定解除？", {btn: ["确定","取消"], shade: 0.5}, function(){
            // 删除权限组
            $.post("{:url('unbind')}", {name: name}, function(res) {
                if (res.code != 200) {
                    layer.msg(res.msg, {shade: 0.5, time: 1000, icon: 2});
                    return false;
                }
                layer.msg(res.msg, {shade: 0.5, time: 1000, icon:1});
                location.href = "{:url('Core/index')}";
            });
        }, function () {});
    }
    //头像
    window.URL = window.URL || window.webkitURL;
    function handleFiles(obj,id) {
        fileList = document.getElementById("fileList");

        var files = obj.files;
        img = new Image();
        if(window.URL){

            img.src = window.URL.createObjectURL(files[0]); //创建一个object URL，并不是你的本地路径
            img.id ="fileimg";
//            img.width = 50;
//            img.height = 50;
            img.onload = function(e) {
                window.URL.revokeObjectURL(this.src); //图片加载后，释放object URL
            }
            // if(fileList.firstElementChild){
            //     fileList.removeChild(fileList.firstElementChild);
            // }
            // console.log(img.src);
            $('#fileimg').attr("src",img.src);
            // fileList.appendChild(img);
        }else if(window.FileReader){
            //opera不支持createObjectURL/revokeObjectURL方法。我们用FileReader对象来处理
            var reader = new FileReader();
            reader.readAsDataURL(files[0]);
            reader.onload = function(e){
                img.src = this.result;
                img.id ="fileimg";
//                img.width = 50;
//                img.height = 50;
                $('#fileimg').attr("src",img.src);

                // fileList.appendChild(img);
            }
        }else
        {
            //ie
            obj.select();
            obj.blur();
            var nfile = document.selection.createRange().text;
            document.selection.empty();
            img.src = nfile;
            img.id ="fileimg";
//            img.width = 50;
//            img.height = 50;

            img.onload=function(){

            }
            $('#fileimg').attr("src",img.src);

            // fileList.appendChild(img);
        }
    }
    function toux_button(){
        $('.toxian').trigger('click');
    }
</script>
</body>
</html>